<template>
  <el-container>
    <!-- 头部区域 -->
    <el-header>
      <div>
        <h1>攀枝花学院毕业设计管理系统</h1>
      </div>
      <div>
        <router-link to="/update" v-model="info"></router-link>
        <router-link to="/updatePwd">
          <el-button @click="loginout" size="small" round>修改密码</el-button>
        </router-link>
        <el-button @click="loginout" size="small">退出</el-button>
      </div>
    </el-header>
    <!-- 主体区域 -->
    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="200px">
        <el-menu :router="true">
          <el-menu-item index="info">
            <i class="el-icon-menu"></i>
            <span slot="title">公告栏</span>
          </el-menu-item>
          <el-menu-item index="article">
            <i class="el-icon-menu"></i>
            <span slot="title">毕业设计（论文）</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <!-- 文本区 -->
      <el-main>
        <!-- 占位符 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  // 生命周期函数
  created() {
    this.getinfo();
  },
  data() {
    return {
      info: "",
    };
  },
  methods: {
    // 退出登录按钮
    loginout() {
      window.sessionStorage.clear;
      this.$router.push("/login");
    },

    // 获取用户信息
    async getinfo() {
      const ret = await this.$http.get("http://127.0.0.1:8080/my/userinfo");
      const text = document.querySelector("el-header,a");
      // console.log(ret.data.data.student_name);
      text.innerHTML =
        ret.data.data[0].student_name +
        "(" +
        ret.data.data[0].student_num +
        ")";
    },
  },
};
</script>

<style lang="less" scoped>
.el-container {
  height: 100%;
}

.el-header {
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
}
.el-header a {
  color: white;
  text-decoration: none;
}

.el-aside {
  background-color: #333743;
}
.el-main {
  background-color: #eaedea;
}
</style>
